<template>
  <n-button v-bind="btnProps" @click="goBack">
    <div class="flex-c">
      <i-return></i-return>
      &nbsp;
      <div>{{ text }}</div>
    </div>
  </n-button>
</template>

<script setup lang="ts">
  const props = defineProps({
    routeName: String,
    routePath: String,
    text: {
      type: String,
      default: '返回'
    },
    btnProps: {
      type: Object,
      default: () => ({})
    }
  })

  const emits = defineEmits(['click'])

  const goBack = () => {
    if (props.routeName) {
      useTabBack({
        name: props.routeName
      })
    } else if (props.routePath) {
      useTabBack({
        path: props.routePath
      })
    }
    emits('click')
  }
</script>

<style lang="less" scoped></style>
